<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  
  <title>Shell Script Getting Start | gdme1320 的笔记</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="Table of Contents   数据类型  数组  字符串拆分为数组     运算  使用  $(( ... ))  方式 expr命令 借助命令完成浮点运算：  bc   awk    If  case   循环  For seq Bash only For Array For files While   定义函数     数据类型    数组   # 以下方式都是bash的特征，">
<meta property="og:type" content="article">
<meta property="og:title" content="Shell Script Getting Start">
<meta property="og:url" content="http://gdme1320.gitee.com/linux/shell/shell-script/index.html">
<meta property="og:site_name" content="gdme1320 的笔记">
<meta property="og:description" content="Table of Contents   数据类型  数组  字符串拆分为数组     运算  使用  $(( ... ))  方式 expr命令 借助命令完成浮点运算：  bc   awk    If  case   循环  For seq Bash only For Array For files While   定义函数     数据类型    数组   # 以下方式都是bash的特征，">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2022-03-23T09:59:43.906Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Shell Script Getting Start">
<meta name="twitter:description" content="Table of Contents   数据类型  数组  字符串拆分为数组     运算  使用  $(( ... ))  方式 expr命令 借助命令完成浮点运算：  bc   awk    If  case   循环  For seq Bash only For Array For files While   定义函数     数据类型    数组   # 以下方式都是bash的特征，">
  
    <link rel="alternate" href="/atom.xml" title="gdme1320 的笔记" type="application/atom+xml">
  
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" integrity="sha384-XdYbMnZ/QjLh6iI4ogqCTaIjrFk87ip+ekIjefZch0Y+PvJ8CDYtEs1ipDmPorQ+" crossorigin="anonymous">

  <link rel="stylesheet" href="/css/styles.css">
  <link rel="stylesheet" href="/css/docs.min.css">
  

</head>
</html>
<body>
  <nav class="navbar navbar-inverse">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="main-menu-navbar">
      <ul class="nav navbar-nav">
        
          <li><a class href="/index.html">Home</a></li>
        
          <li><a class href="/archives/">Archives</a></li>
        
      </ul>

      <!--
      <ul class="nav navbar-nav navbar-right">
        
          <li><a href="/atom.xml" title="RSS Feed"><i class="fa fa-rss"></i></a></li>
        
      </ul>
      -->
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

  <div class="container bs-docs-container">
  
    <div class="row">
        <div class="col-sm-8 blog-main">
          <article id="post-linux/shell/shell-script" class="article article-type-post" itemscope itemprop="blogPost">

  <header class="article-header">
    
  
    <h1 class="article-title" itemprop="name">
      Shell Script Getting Start
    </h1>
  


  </header>

  <div class="article-meta">
    <div class="article-datetime">
  <a href="/linux/shell/shell-script/" class="article-date"><time datetime="2022-03-23T09:59:43.906Z" itemprop="datePublished">2022-03-23</time></a>
</div>

    
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/linux/">linux</a> / <a class="article-category-link" href="/categories/linux/shell/">shell</a>
  </div>


  </div>
  <div class="article-inner">

    <div class="article-entry" itemprop="articleBody">
      
        
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org25a569f">数据类型</a>
<ul>
<li><a href="#org7893c61">数组</a>
<ul>
<li><a href="#org09baca4">字符串拆分为数组</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org356770f">运算</a>
<ul>
<li><a href="#org321dacc">使用  $(( ... ))  方式</a></li>
<li><a href="#org3e7bfb1">expr命令</a></li>
<li><a href="#orgb496070">借助命令完成浮点运算：  bc   awk </a></li>
</ul>
</li>
<li><a href="#orgde67bf8">If</a>
<ul>
<li><a href="#org06592c7">case</a></li>
</ul>
</li>
<li><a href="#org4d13780">循环</a>
<ul>
<li><a href="#org63eed1e">For seq</a></li>
<li><a href="#orge64df09">Bash only</a></li>
<li><a href="#orgad1a702">For Array</a></li>
<li><a href="#org573ff8b">For files</a></li>
<li><a href="#orgb6d907e">While</a></li>
</ul>
</li>
<li><a href="#orgfd2ff86">定义函数</a></li>
</ul>
</div>
</div>
<div class="outline-2" id="outline-container-org25a569f">
<h2 id="org25a569f">数据类型</h2>
<div class="outline-text-2" id="text-org25a569f">
</div>
<div class="outline-3" id="outline-container-org7893c61">
<h3 id="org7893c61">数组</h3>
<div class="outline-text-3" id="text-org7893c61">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">以下方式都是bash的特征，unix shell不支持</span>

<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Define</span>
<span style="font-weight: bold; font-style: italic;">array</span>=(1 2 3 4) <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">元素中间是空格</span>

<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">IndexOf</span>
<span style="font-weight: bold;">echo</span> ${<span style="font-weight: bold; font-style: italic;">array</span>[0]}
${<span style="font-weight: bold; font-style: italic;">arr</span>[*]}         <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">All of the items in the array</span>
${<span style="font-weight: bold; font-style: italic;">!</span>arr[*]}        <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">All of the indexes in the array</span> 
${# <span style="font-weight: bold; font-style: italic;">arr</span>[*]}        <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Number of items in the array</span> 
${# <span style="font-weight: bold; font-style: italic;">arr</span>[0]}        <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Length of item zero</span>

<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Sub list</span>
${<span style="font-weight: bold; font-style: italic;">数组名</span>[@或*]:开始下标:结束下标}

<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Replace Elements</span>
${<span style="font-weight: bold; font-style: italic;">数组名</span>[@或*]/模式/新值}

<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">foreach</span>
<span style="font-weight: bold;">for</span> v<span style="font-weight: bold;"> in</span> ${<span style="font-weight: bold; font-style: italic;">arr_number</span>[@]}; <span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">v</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
</div>
<div class="outline-4" id="outline-container-org09baca4">
<h4 id="org09baca4">字符串拆分为数组</h4>
<div class="outline-text-4" id="text-org09baca4">
<blockquote>
<p>
<a href="http://cncc.bingj.com/cache.aspx?q=shell+cut+string+as+array+variable&amp;d=4788231528388522&amp;mkt=zh-CN&amp;setlang=zh-CN&amp;w=xUC8KzhdRwSBb83YWbtoIpld7nPBFXNn" target="_blank" rel="noopener">http://cncc.bingj.com/cache.aspx?q=shell+cut+string+as+array+variable&amp;d=4788231528388522&amp;mkt=zh-CN&amp;setlang=zh-CN&amp;w=xUC8KzhdRwSBb83YWbtoIpld7nPBFXNn</a>
</p>
</blockquote>
<div class="org-src-container">
<pre class="src src-bash"><span style="font-weight: bold; font-style: italic;">#</span><span style="font-weight: bold; font-style: italic;">!/bin/</span><span style="font-weight: bold;">bash</span>
<span style="font-weight: bold; font-style: italic;">#</span>
<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">Script to split a string based on the delimiter</span>

<span style="font-weight: bold; font-style: italic;">my_string</span>=<span style="font-style: italic;">"Ubuntu;Linux Mint;Debian;Arch;Fedora"</span>  
<span style="font-weight: bold; font-style: italic;">my_array</span>=($(<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">my_string</span> | tr <span style="font-style: italic;">";"</span> <span style="font-style: italic;">"\n"</span>))

<span style="font-weight: bold; font-style: italic;">#</span><span style="font-weight: bold; font-style: italic;">Print the split string</span>
<span style="font-weight: bold;">for</span> i<span style="font-weight: bold;"> in</span> <span style="font-style: italic;">"${my_array[@]}"</span>
<span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="outline-2" id="outline-container-org356770f">
<h2 id="org356770f">运算</h2>
<div class="outline-text-2" id="text-org356770f">
</div>
<div class="outline-3" id="outline-container-org321dacc">
<h3 id="org321dacc">使用  $(( ... ))  方式</h3>
<div class="outline-text-3" id="text-org321dacc">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">b</span>=$((5 * 5+5 - 3/2))
<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">b</span> <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">29</span>

<span style="font-weight: bold; font-style: italic;">i</span>=2
((i++));
<span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"i=$i"</span> <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">i=2</span>
</pre>
</div>
</div>
</div>
<div class="outline-3" id="outline-container-org3e7bfb1">
<h3 id="org3e7bfb1">expr命令</h3>
<div class="outline-text-3" id="text-org3e7bfb1">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">b</span>=$(<span style="font-weight: bold;">expr</span> 5 - 4) <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">important: space is needed</span>
<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">b</span> <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">1</span>
</pre>
</div>
</div>
</div>
<div class="outline-3" id="outline-container-orgb496070">
<h3 id="orgb496070">借助命令完成浮点运算：  bc   awk </h3>
<div class="outline-text-3" id="text-orgb496070">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">c</span>=$(<span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"5.01-4*2.0"</span>|bc) 
<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">c</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">c</span>=$(<span style="font-weight: bold;">awk</span> <span style="font-style: italic;">'BEGIN{print 7.01*5-4.01 }'</span>)
<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">c</span>
</pre>
</div>
</div>
</div>
</div>
<div class="outline-2" id="outline-container-orgde67bf8">
<h2 id="orgde67bf8">If</h2>
<div class="outline-text-2" id="text-orgde67bf8">
</div>
<div class="outline-3" id="outline-container-org06592c7">
<h3 id="org06592c7">case</h3>
<div class="outline-text-3" id="text-org06592c7">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold;">while</span> :
<span style="font-weight: bold;">do</span>
  <span style="font-weight: bold;">read</span> INPUT_STRING
  <span style="font-weight: bold;">case</span> $<span style="font-weight: bold; font-style: italic;">INPUT_STRING</span><span style="font-weight: bold;"> in</span>
        hello)
                <span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"Hello yourself!"</span>
                ;;
        <span style="font-weight: bold;">bye</span>)
                <span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"See you again!"</span>
                <span style="font-weight: bold;">break</span>
                ;;
        *)
                <span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"Sorry, I don't understand"</span>
                ;;
  <span style="font-weight: bold;">esac</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
</div>
</div>
</div>
<div class="outline-2" id="outline-container-org4d13780">
<h2 id="org4d13780">循环</h2>
<div class="outline-text-2" id="text-org4d13780">
</div>
<div class="outline-3" id="outline-container-org63eed1e">
<h3 id="org63eed1e">For seq</h3>
<div class="outline-text-3" id="text-org63eed1e">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">seq 10 用于生成空格间隔的字符串</span>
<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">for spring split with space</span>
<span style="font-weight: bold;">for</span> i<span style="font-weight: bold;"> in</span> $(<span style="font-weight: bold;">seq</span> 10); <span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>
<span style="font-weight: bold;">done</span>
<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">output: 1 2 3 4 ... 10</span>
</pre>
</div>
</div>
</div>
<div class="outline-3" id="outline-container-orge64df09">
<h3 id="orge64df09">Bash only</h3>
<div class="outline-text-3" id="text-orge64df09">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">下面的表达式不支持sh, 需要bash</span>
<span style="font-weight: bold;">for</span> (( <span style="font-weight: bold; font-style: italic;">i</span>=1; i&lt;=10; i++ ))
<span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
</div>
</div>
<div class="outline-3" id="outline-container-orgad1a702">
<h3 id="orgad1a702">For Array</h3>
<div class="outline-text-3" id="text-orgad1a702">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">for array</span>
<span style="font-weight: bold;">for</span> i<span style="font-weight: bold;"> in</span> {1..10}; <span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
<p>
注意这各方式，在括号内不能再使用变量了，下面的是错误的
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">max</span>=10
<span style="font-weight: bold;">for</span> i<span style="font-weight: bold;"> in</span> {1..$<span style="font-weight: bold; font-style: italic;">max</span>}; <span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
<p>
这样输出的结果是  {1..$max} 
</p>
<blockquote>
nil</blockquote>
</div>
</div>
<div class="outline-3" id="outline-container-org573ff8b">
<h3 id="org573ff8b">For files</h3>
<div class="outline-text-3" id="text-org573ff8b">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold;">for</span> file<span style="font-weight: bold;"> in</span> /usr/local/bin/*;
<span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">file</span> is file path <span style="font-style: italic;">\!</span> ; <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">file 是文件的全路径</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
<p>
这种方式能够处理文件名包含空格的情况，而  for file in `ls /usr/local/bin`  如果目录下有文件名有空格，则会被作为两个。
</p>
</div>
</div>
<div class="outline-3" id="outline-container-orgb6d907e">
<h3 id="orgb6d907e">While</h3>
<div class="outline-text-3" id="text-orgb6d907e">
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;">i</span>=0
<span style="font-weight: bold;">while</span> [ $<span style="font-weight: bold; font-style: italic;">i</span> -lt 4 ]; <span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">i</span>;
    <span style="font-weight: bold; font-style: italic;">i</span>=<span style="font-weight: bold;">`expr $i + 1`</span>; <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">更多运算表达式查看arithmetic.sh</span>
<span style="font-weight: bold;">done</span>
<span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">也能够不加条件</span>
<span style="font-weight: bold;">while</span> :
<span style="font-weight: bold;">do</span>
    <span style="font-weight: bold;">echo</span> <span style="font-style: italic;">"doing..."</span>
    <span style="font-weight: bold;">break</span>
<span style="font-weight: bold;">done</span>
</pre>
</div>
</div>
</div>
</div>
<div class="outline-2" id="outline-container-orgfd2ff86">
<h2 id="orgfd2ff86">定义函数</h2>
<div class="outline-text-2" id="text-orgfd2ff86">
<ul class="org-ul">
<li>可以带function fun() 定义，也可以直接fun() 定义,不带任何参数。</li>
<li>参数返回，可以显示加：return 返回，如果不加，将以最后一条命令运行结果，作为返回值。 return后跟数值n(0-255</li>
<li>必须在调用函数地方之前，声明函数，shell脚本是逐行运行。不会像其它语言一样先预编译。一次必须在使用函数前先声明函数。</li>
<li>我们可以将shell中函数，看作是定义一个新的命令，它是命令，因此 各个输入参数直接用 空格分隔。 一次，命令里面获得参数方法可以通过：$0…$n得到。 $0代表函数本身。</li>
<li>定义函数可以与系统命令相同，说明shell搜索命令时候，首先会在当前的shell文件定义好的地方查找，找到直接执行。通过$?获得函数值</li>
<li>如果需要定义自己变量，可以在函数中定义：local 变量=值 ，这时变量就是内部变量，它的修改，不会影响函数外部相同变量的值 。</li>
</ul>
<p>
基本语法：
</p>
<div class="org-src-container">
<pre class="src src-sh">[ <span style="font-weight: bold;">function</span> ] funname [()]
{
    action;
    [return int;]
} 
</pre>
</div>
<p>
例如：
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold;">function</span> <span style="font-weight: bold;">fSum</span>() <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">parameter list is $1, $2, ...</span>
{
    <span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">1</span>,$<span style="font-weight: bold; font-style: italic;">2</span>;  <span style="font-weight: bold; font-style: italic;">#</span><span style="font-weight: bold; font-style: italic;">　参数</span>
    <span style="font-weight: bold;">return</span> $(($<span style="font-weight: bold; font-style: italic;">1</span>+$<span style="font-weight: bold; font-style: italic;">2</span>));
}
</pre>
</div>
<p>
调用函数就像调用命令一样：
</p>
<div class="org-src-container">
<pre class="src src-sh">fSum 5 7;
<span style="font-weight: bold; font-style: italic;">total</span>=$(<span style="font-weight: bold;">fSum</span> 3 2); <span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">调用方法</span>
<span style="font-weight: bold;">echo</span> $<span style="font-weight: bold; font-style: italic;">total</span>,$<span style="font-weight: bold; font-style: italic;">?</span>;
</pre>
</div>
</div>
</div>
</div>
<div class="status" id="postamble">
<p class="author">Author: gdme1320</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer" target="_blank" rel="noopener">Validate</a></p>
</div>

      
    </div>

    
      

    

    <footer class="article-footer">
      <a data-url="http://gdme1320.gitee.com/linux/shell/shell-script/" data-id="cl13eo7mv00ezhjv4ho3so05j" class="article-share-link">
        <i class="fa fa-share"></i> Share
      </a>
      
      

    </footer>
  </div>
  
    
<ul id="article-nav" class="nav nav-pills nav-justified">
  
  <li role="presentation">
    <a href="/linux/tcp/network-tcp-performance-turning-with-sysctl/" id="article-nav-older" class="article-nav-link-wrap">
      <i class="fa fa-chevron-left pull-left"></i>
      <span class="article-nav-link-title">【翻译】Sysctl调节Linux网络性能</span>
    </a>
  </li>
  
  
  <li role="presentation">
    <a href="/linux/shell/bash_cgi/" id="article-nav-newer" class="article-nav-link-wrap">
      <span class="article-nav-link-title">Script for Shell Parsing Parameters</span>
      <i class="fa fa-chevron-right pull-right"></i>
    </a>
  </li>
  
</ul>


  
</article>




        </div>
        <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
          
  
  <div class="sidebar-module">
    <h4>Categories</h4>
    <ul class="sidebar-module-list"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/apps/">apps</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/architecture/">architecture</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/devops/">devops</a><span class="sidebar-module-list-count">10</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/devops/kubectl/">kubectl</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/devops/kubernetes/">kubernetes</a><span class="sidebar-module-list-count">3</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/dotnet/">dotnet</a><span class="sidebar-module-list-count">3</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/dotnet/entityframework/">entityframework</a><span class="sidebar-module-list-count">1</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/elasticsearch/">elasticsearch</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/emacs/">emacs</a><span class="sidebar-module-list-count">4</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/emacs/org-mode/">org-mode</a><span class="sidebar-module-list-count">3</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/git/">git</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/graphql/">graphql</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/groovy/">groovy</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/">java</a><span class="sidebar-module-list-count">52</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/concurrent/">concurrent</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/jackson/">jackson</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/shiro/">shiro</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/spring/">spring</a><span class="sidebar-module-list-count">11</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/spring-amqp/">spring-amqp</a><span class="sidebar-module-list-count">5</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/spring-amqp/spring-jpa/">spring-jpa</a><span class="sidebar-module-list-count">1</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/spring-jpa/">spring-jpa</a><span class="sidebar-module-list-count">10</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/spring-security/">spring-security</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/thymeleaf/">thymeleaf</a><span class="sidebar-module-list-count">2</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/java/thymeleaf/maven/">maven</a><span class="sidebar-module-list-count">1</span></li></ul></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/jenkins/">jenkins</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/journal/">journal</a><span class="sidebar-module-list-count">7</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/js/">js</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/">linux</a><span class="sidebar-module-list-count">35</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/kde/">kde</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/kross/">kross</a><span class="sidebar-module-list-count">3</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/kross/ktorrent-scripts/">ktorrent-scripts</a><span class="sidebar-module-list-count">1</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/shell/">shell</a><span class="sidebar-module-list-count">6</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/linux/tcp/">tcp</a><span class="sidebar-module-list-count">1</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/lisp/">lisp</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/mongodb/">mongodb</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/mssql/">mssql</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/mysql/">mysql</a><span class="sidebar-module-list-count">12</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/nginx/">nginx</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/node/">node</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/postgresql/">postgresql</a><span class="sidebar-module-list-count">2</span><ul class="sidebar-module-list-child"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/postgresql/client/">client</a><span class="sidebar-module-list-count">1</span></li></ul></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/python/">python</a><span class="sidebar-module-list-count">19</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/regex/">regex</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/rfc/">rfc</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/vim/">vim</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/categories/windows/">windows</a><span class="sidebar-module-list-count">7</span></li></ul>
  </div>



  
  <div class="sidebar-module">
    <h4>Tags</h4>
    <ul class="sidebar-module-list"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/tags/ReentrantLock/">ReentrantLock</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/tags/nohup/">nohup</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/tags/pandoc/">pandoc</a><span class="sidebar-module-list-count">1</span></li></ul>
  </div>



  
  <div class="sidebar-module">
    <h4>Tag Cloud</h4>
    <p class="tagcloud">
      <a href="/tags/ReentrantLock/" style="font-size: 10px;">ReentrantLock</a> <a href="/tags/nohup/" style="font-size: 10px;">nohup</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a>
    </p>
  </div>


  
  <div class="sidebar-module">
    <h4>Archives</h4>
    <ul class="sidebar-module-list"><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2919/06/">June 2919</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2022/03/">March 2022</a><span class="sidebar-module-list-count">58</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2022/01/">January 2022</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/11/">November 2021</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/10/">October 2021</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/04/">April 2021</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/03/">March 2021</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/02/">February 2021</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2021/01/">January 2021</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/12/">December 2020</a><span class="sidebar-module-list-count">2</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/11/">November 2020</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/10/">October 2020</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/09/">September 2020</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/07/">July 2020</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/06/">June 2020</a><span class="sidebar-module-list-count">10</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/04/">April 2020</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/03/">March 2020</a><span class="sidebar-module-list-count">8</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/02/">February 2020</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2020/01/">January 2020</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/12/">December 2019</a><span class="sidebar-module-list-count">7</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/11/">November 2019</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/10/">October 2019</a><span class="sidebar-module-list-count">11</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/09/">September 2019</a><span class="sidebar-module-list-count">6</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/08/">August 2019</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/07/">July 2019</a><span class="sidebar-module-list-count">10</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/06/">June 2019</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/05/">May 2019</a><span class="sidebar-module-list-count">3</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/04/">April 2019</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/03/">March 2019</a><span class="sidebar-module-list-count">8</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/02/">February 2019</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2019/01/">January 2019</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/11/">November 2018</a><span class="sidebar-module-list-count">4</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/10/">October 2018</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/08/">August 2018</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/07/">July 2018</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/06/">June 2018</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2018/03/">March 2018</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2017/07/">July 2017</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2017/06/">June 2017</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2017/04/">April 2017</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/2015/05/">May 2015</a><span class="sidebar-module-list-count">1</span></li><li class="sidebar-module-list-item"><a class="sidebar-module-list-link" href="/archives/1970/01/">January 1970</a><span class="sidebar-module-list-count">9</span></li></ul>
  </div>



  
  <div class="sidebar-module">
    <h4>Recents</h4>
    <ul class="sidebar-module-list">
      
        <li>
          <a href="/java/acessing-generic-types-at-runtime/">获取泛型类型</a>
        </li>
      
        <li>
          <a href="/linux/shell/bash_cgi/">Script for Shell Parsing Parameters</a>
        </li>
      
        <li>
          <a href="/linux/shell/shell-script/">Shell Script Getting Start</a>
        </li>
      
        <li>
          <a href="/linux/tcp/network-tcp-performance-turning-with-sysctl/">【翻译】Sysctl调节Linux网络性能</a>
        </li>
      
        <li>
          <a href="/java/concurrent/aqs-src/">AQS源码笔记</a>
        </li>
      
    </ul>
  </div>



        </div>
    </div>
  </div>
  <footer class="blog-footer">
  <div class="container">
    <div id="footer-info" class="inner">
      &copy; 2022 gdme1320<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

  

<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script> -->

<script src="/js/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>



<script src="/js/script.js"></script>

</body>
</html>
